package controller;


import java.io.IOException;
import java.util.List;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.Domain;

import data.Data;


@SuppressWarnings("serial")

public class SitemapServlet extends HttpServlet {
	@SuppressWarnings("unchecked")
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		
		PersistenceManager psm = Data.get().getPersistenceManager();
		Query query = psm.newQuery(Domain.class);
		query.setOrdering("update desc");
		query.setRange(0,500);

		List<Domain> domainList = (List<Domain>) query.execute();
		
		req.setAttribute("domainList", domainList);
	
		try {
			req.getRequestDispatcher("/sitemap.jsp").forward(req, resp);
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

